﻿@model CloudStorageLight.Web.Models.UsersVM
@{
    ViewBag.Title = CloudStorageLight.Core.Web.ViewMessages.CmdUserList;
    Layout = "~/Views/Shared/_LayoutCloudStorage.cshtml";
    bool disableLogin = CloudStorageLight.Core.SystemSettings.Instance.DisableLogin;
}

<header class="nrm nlm">
    <div class="clearfix bg-darkBlue fg-white" id="header-cont">
        <div class="place-right">
            <div class="margin10">
                <i class="icon-user"></i>
                @(Model.Current.UserName.Split('@')[0])
                <a id="logoff" href="@Url.Action("LogOff", "Account")"><i class="icon-exit" title="logoff" style="background:white;color:blue;padding:10px;border-radius:50%"></i></a>
            </div>

        </div>

        <div class="place-left margin10">
            <nav class="horizontal-menu">
                <ul>
                    @Html.Partial("_HomeCommand")
                    <li>@Html.ActionLink(CloudStorageLight.Core.Web.ViewMessages.CmdListUser, "UserList", null, new { @class = "command-link" })</li>
                    <li><a id="adduser-command" class="command-link" href="javascript:void(0);">@(CloudStorageLight.Core.Web.ViewMessages.CmdAddUser)</a></li>
                </ul>
            </nav>
        </div>

        <div class="place-right">
            <div class="input-control text size4 margin10">
                <input type="text" id="user-query" name="user-query" placeholder="Search..." value="@(Model.Query)">
                <button id="search-user" class="btn-search"></button>
            </div>
        </div>
    </div>
</header>
<div style="height:100%;">
    <p>@Model.Message</p>
    <div id="users-cont" class="listview-outlook" style="height:100%;">
        @foreach (var user in Model.Users)
        {
            @Html.Partial("_BlobUser", user)
        }
    </div>

    <div id="grouplist-cont" style="display:none;">
        <div id="grouplist" style="position:relative;height:400px;width:320px;">
            <div style="overflow:auto;position:absolute;top:0px;left:10px;bottom:60px;right:10px   ;">
                <table>
                    <tr>
                        <td><input id="newRole" type="text" /></td>
                        <td><button id="addNewRole" class="button" type="button">@(CloudStorageLight.Core.Web.ViewMessages.MsgAdd)</button></td>
                    </tr>
                </table>
                               
                <ul>
                    @foreach (var item in Model.Groups)
                    {
                        <li>
                            <input name='@item' type='checkbox'>
                            <span>@item</span>
                        </li>
                    }
                </ul>
            </div>
            <div style="position:absolute;height:50px;bottom:0px;right:10px;left:10px;padding-top:10px;">
                <button id="rolesave" class="button" type="button">@(CloudStorageLight.Core.Web.ViewMessages.MsgSetValue)</button>
                <button id="roleclose" class="button" type="button">@(CloudStorageLight.Core.Web.ViewMessages.MsgCancel)</button>
            </div>
        </div>
    </div>
    <div id="adduser-cont" style="display:none;">
        @using (Html.BeginForm("addUser", null, null, FormMethod.Post, new { id = "addUserForm" }))
        {
            <table style="width:450px;padding:50px;">
                <tr>
                    <td>@CloudStorageLight.Core.Web.ViewMessages.MsgUserName</td>
                    <td>@Html.TextBox("username")</td>
                </tr>
                <tr>
                    <td>@CloudStorageLight.Core.Web.ViewMessages.MsgNewPassword</td>
                    <td>@Html.Password("userpassword")</td>
                </tr>
                <tr>
                    <td>@CloudStorageLight.Core.Web.ViewMessages.MsgConfirmPassword</td>
                    <td>@Html.Password("confirmuserpassword")</td>
                </tr>
                <tr>
                    <td><div style="height:50px;"></div></td>
                    <td></td>
                </tr>
                <tr>
                    <td>
                        <button id="adduser" type="button" class="button">
                            @CloudStorageLight.Core.Web.ViewMessages.MsgAdd
                        </button>

                    </td>
                    <td></td>
                </tr>
            </table>
        }
    </div>
    <div id="reset-user-password-cont" style="display:none;">
        @using (Html.BeginForm("resetUserPassword", null, null, FormMethod.Post, new { id = "resetUserPasswordForm" }))
        {
            <table style="width:450px;padding:50px;">
                <tr>
                    <td>@CloudStorageLight.Core.Web.ViewMessages.MsgUserName</td>
                    <td>@Html.TextBox("resetUsername", null, new { @readonly = "readonly"})</td>
                </tr>
                <tr>
                    <td>@CloudStorageLight.Core.Web.ViewMessages.MsgNewPassword</td>
                    <td>@Html.Password("resetUserpassword")</td>
                </tr>
                <tr>
                    <td>@CloudStorageLight.Core.Web.ViewMessages.MsgConfirmPassword</td>
                    <td>@Html.Password("resetConfirmuserpassword")</td>
                </tr>
                <tr>
                    <td><div style="height:50px;"></div></td>
                    <td></td>
                </tr>
                <tr>
                    <td>
                        <button id="resetPassword" type="button" class="button">
                            @CloudStorageLight.Core.Web.ViewMessages.MsgResetPassword
                        </button>

                    </td>
                    <td></td>
                </tr>
            </table>
        }
    </div>

</div>

@section scripts{
    <script>
        @Html.Partial("_Message")

        $(function () {
            CloudStorageLight.StorageController.bindUserList();
            $("#search-user").click(function () {
                CloudStorageLight.StorageController.searchUsers($("#user-query").val());
            });
            $("#user-query").keypress(function (e) {
                if (e.keyCode == 13) {
                    CloudStorageLight.StorageController.searchUsers($("#user-query").val());
                }
            });
            $('#adduser-command').click(function () {
                CloudStorageLight.StorageController.showAddUser();
            });
            $(".delete-user").unbind().click(function () {
                CloudStorageLight.StorageController.deleteUser($(this).closest(".list"));
            });

        });
    </script>
}


